package com.objecteffects.template.web.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.scribe.exceptions.OAuthException;

import org.apache.commons.lang3.exception.ExceptionUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.exception.DefaultExceptionHandler;

/**
 * @author Rusty Wright
 */
public class TemplateExceptionHandler extends DefaultExceptionHandler {
    private final transient Logger log = LoggerFactory
        .getLogger(TemplateExceptionHandler.class);

    private static final String ERROR_VIEW = "/WEB-INF/jsp/show_error.jsp";

    /**
     * @param req
     * @param res
     */
    public Resolution handle(final OAuthException ex,
        final HttpServletRequest req, final HttpServletResponse res) {
        this.log.error(ExceptionUtils.getStackTrace(ex));

        return new ForwardResolution(TemplateExceptionHandler.ERROR_VIEW);
    }
}
